home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / FROMUTS / CDUNGEON / !CDUNGEON / c / LOCAL < prev    next >
Text File  |  1991-05-20  |  2KB  |  82 lines

  1. /* local.c -- dungeon functions which need local definition */
  2.  
  3. #include "funcs.h"
  4.  
  5. #ifdef __AMOS__
  6. #include <moncal.h>
  7. #endif
  8.  
  9. /* This function should return TRUE_ if it's OK for people to play the
  10.  * game, FALSE_ otherwise.  If you have a working <time.h> library,
  11.  * you can define NONBUSINESS to disallow play Monday to Friday, 9-5
  12.  * (this is only checked at the start of the game, though).  For more
  13.  * complex control you will have to write your own version of this
  14.  * function.
  15.  */
  16.  
  17. #ifdef NONBUSINESS
  18. #ifdef BSD4_2
  19. #include <sys/timeb.h>
  20. #else /* ! BSD4_2 */
  21. #include <time.h>
  22. #endif /* ! BSD4_2 */
  23. #endif /* NONBUSINESS */
  24.  
  25. logical protected()
  26. {
  27. #ifndef NONBUSINESS
  28.  
  29.     return TRUE_;
  30.  
  31. #else /* NONBUSINESS */
  32.  
  33.     time_t t;
  34.     struct tm *q;
  35.  
  36.     (void)time(&t);
  37.     q = localtime(&t);
  38.  
  39.     /* Return TRUE_ if it's Sunday or Saturday or before 9 or after 5 */
  40.  
  41.     if (q->tm_wday == 0 || q->tm_wday == 6)
  42.     return TRUE_;
  43.     else if (q->tm_hour < 9 || q->tm_hour >= 17)
  44.     return TRUE_;
  45.     else
  46.     return FALSE_;
  47.  
  48. #endif /* NONBUSINESS */
  49.  
  50. }
  51.  
  52. #ifdef ALLOW_GDT
  53.  
  54. /* This function should return TRUE_ if the user is allowed to invoke the
  55.  * game debugging tool by typing "gdt".  This isn't very useful without
  56.  * the source code, and it's mainly for people trying to debug the game.
  57.  * You can define WIZARDID to specify a user id on a UNIX system.  On a
  58.  * non AMOS, non unix system this function will have to be changed if
  59.  * you want to use gdt.
  60.  */
  61.  
  62. #ifndef WIZARDID
  63. #define WIZARDID (0)
  64. #endif
  65.  
  66. logical wizard()
  67. {
  68. #ifdef __AMOS__
  69.     if (jobidx()->jobusr == 0x102)
  70.     return TRUE_;
  71. #else
  72. #ifdef unix
  73.     if (getuid() == 0 || getuid() == WIZARDID)
  74.     return TRUE_;
  75. #endif
  76. #endif
  77.  
  78.     return FALSE_;
  79. }
  80.  
  81. #endif
  82.